package com.herui.ota.controller;

import com.herui.ota.config.ControllerNames;
import com.herui.ota.entity.DeviceOta;
import com.herui.ota.entity.DeviceOtaEvent;
import com.herui.ota.pojo.form.DeviceOtaEventFilterForm;
import com.herui.ota.pojo.form.DeviceOtaFilterForm;
import com.herui.ota.pojo.vo.DeviceOtaEventChannel;
import com.herui.ota.service.DeviceOtaEventService;
import com.herui.ota.service.DeviceOtaService;
import com.mlnx.common.entity.ResponseData;
import io.swagger.annotations.Api;
import org.shan.spring.base.CurdBaseController;
import org.shan.spring.base.annotations.SysLog;
import org.shan.spring.mybatis.service.ICurdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@Api(value = ControllerNames.DEVICEOTAName + "接口", tags = {ControllerNames.DEVICEOTAName + "接口"})
@SysLog(title = ControllerNames.DEVICEOTAName)
@RestController
@RequestMapping("/otaevent")
public class DeviceOtaEventController extends CurdBaseController<DeviceOtaEvent, DeviceOtaEvent,
        DeviceOtaEvent, DeviceOtaEventFilterForm> {
    @Autowired
    private DeviceOtaEventService service;

    @Override
    public ICurdService getService() {
        return service;
    }

    @Override
    public DeviceOtaEvent newInstance(Integer id) {
        DeviceOtaEvent soft = new DeviceOtaEvent();
        soft.setId(id);
        return soft;
    }


    @GetMapping("/deviceOtaEventChannel")
    public ResponseData<List<DeviceOtaEventChannel> > download(String version) throws IOException {
        List<DeviceOtaEventChannel> deviceOtaEventChannels = service.listDeviceOtaEventChannel(version);
        return result(deviceOtaEventChannels);
    }

}
